package com.hd.openapi.servies.serviceimpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hd.openapi.common.ResponseResult;
import com.hd.openapi.common.ResultTable;
import com.hd.openapi.dao.CustomerMapper;
import com.hd.openapi.entity.Customer;
import com.hd.openapi.servies.customerser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class customerimpl implements customerser {
    @Autowired
    public CustomerMapper ct;
    @Override
    public ResultTable getdata(Integer page, Integer limit, String name, String state) {
        PageHelper.startPage (page,limit);
        List<Customer> a=ct.getdatada(name,state);
        PageInfo aa=new PageInfo (a);
        return new ResultTable (0,"",(int) aa.getTotal (),aa.getList ());
    }

    @Override
    public ResponseResult adddata(Customer customer) {
        int i = ct.insertSelective (customer);
        return ResponseResult.getSuccess ();
    }

    @Override
    public ResponseResult updatadata(Customer customer) {
        int i = ct.updateByPrimaryKeySelective (customer);
        return ResponseResult.getSuccess ();
    }

    @Override
    public ResponseResult deldata(Integer[] ids) {
         int i=ct.delda(ids);
        return ResponseResult.getSuccess ();
    }
}
